package com.usooft.metaTalent.core.system.service.basic;

import com.usooft.metaTalent.core.system.entity.Role;
import com.usooft.metaTalent.core.system.query.RoleQuery;
import com.usooft.metaTalent.core.system.service.RoleService;
import com.usooft.metaTalent.core.system.service.base.BaseRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class BasicRoleService extends BaseRoleService implements RoleService {

    // region 自动生成
    // endregion

    @Override
    public List<? extends Role> listAll() {
        return list(RoleQuery.builder().build());
    }

    @Override
    @Transactional
    public Role create(String name, String description) {
        return internalAdd(name, description);
    }

    @Override
    @Transactional
    public void edit(Role role, String name, String description) {
        role.setName(name);
        role.setDescription(description);

        internalUpdate(role);
    }
}